﻿

//        错误的请求结果 BadRequestResult 400
//冲突结果 ConflictResult 409
//没有内容结果 NoContentResult 204
//没有找到结果 NotFoundResult 404
//好的结果 OkResult 200
//未经授权的结果 UnauthorizedResult 401
//不可处理的实体结果 UnprocessableEntityResult 422
//不支持的媒体类型结果 UnsupportedMediaTypeResult 415
//内部服务器错误结果 InternalServerErrorResult 500

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace HZY.Admin.Controllers
{
    using System.Net;
    using HZY.DTO.Core;
    using Microsoft.AspNetCore.Mvc.Infrastructure;

    [Route("Admin/[controller]")]
    [ApiController]
    public class BaseController : ControllerBase
    {

        [NonAction]
        public virtual ObjectResult StatusCode([ActionResultStatusCode]HttpStatusCode statusCode, [ActionResultObjectValue] object value)
            => this.StatusCode((int)statusCode, value);

        [NonAction]
        public virtual StatusCodeResult StatusCode([ActionResultStatusCode] HttpStatusCode statusCode)
            => this.StatusCode((int)statusCode);

        /// <summary>
        /// OK 成功返回 200 并带有返回值
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        [NonAction]
        public virtual ObjectResult StatusCodeOK([ActionResultObjectValue] object value)
            => this.StatusCode((int)HttpStatusCode.OK, value);

        /// <summary>
        /// OK 成功返回 200
        /// </summary>
        /// <returns></returns>
        [NonAction]
        public virtual StatusCodeResult StatusCodeOK()
            => this.StatusCode((int)HttpStatusCode.OK);

        /// <summary>
        /// Error 错误 返回 400
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        [NonAction]
        public virtual ObjectResult StatusCodeError([ActionResultObjectValue] object value)
            => this.StatusCode((int)HttpStatusCode.BadRequest, value);


    }
}